package app

type OnceTask struct {
	deviceMap  map[uint32]*Device
	productMap map[uint32]*Product
}

func NewTask(devices []*Device, products []*Product) (*OnceTask, error) {
	t := &OnceTask{
		deviceMap:  make(map[uint32]*Device, len(devices)),
		productMap: make(map[uint32]*Product, len(products)),
	}

	for _, p := range products {
		t.productMap[p.ProductId] = p
	}
	for _, d := range devices {
		t.deviceMap[d.DeviceId] = d
	}

	return t, nil
}

// 获取设备的任务,如果为空, 那么旧延迟返回, 执行完成/或者为空
func (tTask *OnceTask) Next(deviceId uint32) *Product {
	return nil
}

// 所有任务, 所有设备完成后为true
func (tTask *OnceTask) IsDone() bool {
	return false
}
